<?php 
defined('_JEXEC') or die;
$db =& JFactory::getDBO();
$query="select * from #__menu where menutype='footer' and parent_id=1 and published = 1 order by ordering,lft";
$db->setQuery($query);
$level1=$db->loadObjectList();
foreach ($level1 as $item)
{
	echo "<ul>";
	echo "<h3>".$item->title."</h3>";
	$query="select * from #__menu where menutype='footer' and parent_id=".$item->id." and published = 1 order by ordering,lft";
	$db->setQuery($query);
	$level2=$db->loadObjectList();
	foreach ($level2 as $item1)
	{
		//var_dump($item1);die;
		echo "<li><a href='".JRoute::_($item1->link.'&Itemid='.$item1->id)."'>".$item1->title."</a></li>";
	}
	echo "</ul>";
}
  
?>